<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>产品发布</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="admin.css" rel="stylesheet" type="text/css" />
<script src="<{$config.weburl}>/script/jquery-1.4.4.min.js" type="text/javascript" charset="utf-8" ></script>
<script src="<{$config.weburl}>/script/my_lightbox.js" type="text/javascript" charset="utf-8"></script>
<script src="<{$config.weburl}>/script/district.js" type="text/javascript" charset="utf-8"></script>
<script src="<{$config.weburl}>/script/jquery.json-2.4.js" type="text/javascript" charset="utf-8"></script>
<script language="javascript">
var weburl="<{$config.weburl}>";
$(function(){
	$('#customs_cat').bind('change',function(){
		var __this = $(this);
		var rate = __this.find("option:selected").attr('rate');
		var hscode = __this.find("option:selected").attr('hscode');
		var tax_paid_price = __this.find("option:selected").attr('tax_paid_price');
		if(rate>0 && hscode!=''){
			$('#tax_rate').val(rate);
			$('#hscode').val(hscode);
			$('#tax_paid_price').val(tax_paid_price);
		}
	});
	$('#hscodeForSearch').bind('input',function(){
		var hscodetemp = $(this).val();
		if(hscodetemp.length==8){
		    $.get('<{$config.weburl}>/admin/module.php?m=product&s=product_launch.php&operation=getCatByHscode&hscode='+hscodetemp,function(data){
		    	var d = eval('('+data+')');
		    	if(d.catid>0){
		    		var chtml = '<option value="'+d.catid+'" rate="'+d.tax_rate+'" hscode="'+d.hscode+'" tax_paid_price="'+d.tax_paid_price+'">'+d.cat+'</option>';
			    	$('#customs_cat').html(chtml);
			    	$('#tax_rate').val(d.tax_rate);
		            $('#hscode').val(d.hscode);
		            $('#tax_paid_price').val(d.tax_paid_price);
		    	}
	        });
		}
	});
});
</script>
</head>
<body>
<div class="container">
<div class="flow">
    <div class="itemtitle">
        <h3>产品详情</h3>
        <ul>
            <li class="current"><a id="base" href="javascript:;"><span>基本信息</span></a></li>
            <{if $firstvalue.d.0}><li><a id="spec" href="javascript:;"><span>销售属性</span></a></li><{/if}>
            <{if $firstvalue.s.0}><li><a id="other" href="javascript:;"><span>其它属性</span></a></li><{/if}>
            <{if $firstvalue.p}><li><a id="parameter" href="javascript:;"><span>详细参数</span></a></li><{/if}>
            <{if $service}><li><a id="service" href="javascript:;"><span>产品服务</span></a></li><{/if}>
            <li><a id="detail" href="javascript:;"><span>商品详情</span></a></li>
            <li><a id="logistics" href="javascript:;"><span>物流信息</span></a></li>
        <!--     <li><a id="parts" href="javascript:;"><span>推荐组合</span></a></li>
            <li><a id="give" href="javascript:;"><span>赠送产品</span></a></li> -->
            <li><a id="related" href="javascript:;"><span>相关产品</span></a></li>
        </ul>
    </div>
</div>
<div class="h35"></div>
<form method="post" action="" enctype="multipart/form-data" onsubmit="return check_value();">
    <table class="table" id="base">
    <thead>
    <tr>
        <th colspan="2" class="partition">基本信息</th>
    </tr>
    </thead>
    
    <tbody>
    <tr>
        <td width="100">所属分类</td>
        <td>
         <{$typenames}>
        <{if !$smarty.get.catid}>
        <input name="catid" id="catid" type="hidden" value="<{$de.catid}>" />
        <input name="tcatid" id="tcatid" type="hidden" value="<{$de.tcatid}>" />
        <input name="scatid" id="scatid" type="hidden" value="<{$de.scatid}>" />
        <input name="sscatid" id="sscatid" type="hidden" value="<{$de.sscatid}>" />
        <{else}>
        <input name="catid" id="catid" type="hidden" value="<{$smarty.get.catid}>" />
        <input name="tcatid" id="tcatid" type="hidden" value="<{$smarty.get.tcatid}>" />
        <input name="scatid" id="scatid" type="hidden" value="<{$smarty.get.scatid}>" />
        <input name="sscatid" id="sscatid" type="hidden" value="<{$smarty.get.sscatid}>" />
        <a href="module.php?m=product&s=product_launch.php&editid=<{$smarty.get.edit}>&cat=<{$smarty.get.catid}>&tcatid=<{$smarty.get.tcatid}>&scatid=<{$smarty.get.scatid}>&sscatid=<{$smarty.get.sscatid}>">编辑</a>
        <{/if}>
        </td>
    </tr>
    <tr>
        <td>产品编号</td>
        <td><input value="<{if $de.code}><{$de.code}><{else}>添加商品自动生成<{/if}>" name="code" type="text" class="w350" disabled  /></td>
    </tr>
    
    <tr>
      <td>产品名称</td>
      <td><input maxlength="100" name="title" type="text" id="title" class="w350" value="<{$de.pname}>" /></td>
    </tr>
    
    <tr>
      <td>副标题/促销提示</td>
      <td>
      <textarea name="promotion_tips"   id="promotion_tips" class="w350" ><{$de.promotion_tips}></textarea>
      </td>
    </tr>
    
    <tr>
      <td>国家</td>
      <td><input maxlength="100" name="guojia" type="text" id="guojia" class="w350" value="<{$de.guojia}>" /></td>
    </tr>
    
    
     <tr>
        <td>国家图标</td>
        <td>
        <input name="guojiapic" class="w350" type="text" id="guojiapic" value="<{$de.guojiapic}>" />
        [<a href="javascript:uploadfile('上传LOGO','guojiapic',42,42,'tags')">上传</a>] 
        [<a href="javascript:preview('guojiapic');">预览</a>]
        [<a onclick="javascript:$('#guojiapic').val('');" href="#">删除</a>] <span class="bz"></span>
        </td>
    </tr>
    
    <tr>
      <td>短描述(120字内)</td>
      <td>
      <textarea name="short_desc"   id="short_desc" class="w350" style="height:30px;"><{$de.short_desc}></textarea>
      </td>
    </tr>
    
    
        <tr>
        <td>标签</td>
        <td>
        
        <select class="w200" id="tags" name='tags[]' multiple="multiple" size="10" style="height:auto;">
                        <{foreach item=list from=$tags}>
                        
             			<option <{if $list.stags}> disabled <{/if}> <{if  @$list.id|in_array:$de.tags}> selected="selected" <{/if}> value="<{$list.id}>"><{$list.tags}></option>
                           
                            <{foreach item=slist from=$list.stags}>
                            <option <{if $slist.stags}> disabled <{/if}> <{if @$slist.id|in_array:$de.tags}> selected="selected" <{/if}> value="<{$slist.id}>">|__<{$slist.tags}></option>
                            	    
                                    <{foreach item=sslist from=$slist.stags}>
                                    <option <{if $sslist.stags}> disabled <{/if}> <{if @$sslist.id|in_array:$de.tags}> selected="selected" <{/if}> value="<{$sslist.id}>">|____<{$sslist.tags}></option>
                                    
                                    <{foreach item=lists from=$sslist.stags}>
                                    <option <{if @$lists.id|in_array:$de.tags}> selected="selected" <{/if}> value="<{$lists.id}>">|______<{$lists.tags}></option>
                            		<{/foreach}>
                            		<{/foreach}> 
                                    
                            <{/foreach}> 
                            
                        <{/foreach}> 
            		</select>
 按住 “CTRL” 多选
        </td>
    </tr>
    
    <!-- <tr>
      <td>品名</td>
      <td><input name="ftitle" type="text" id="ftitle" class="w350" value="<{$de.ftitle}>" /></td>
    </tr> -->
    
    <tr>
        <td><{$lang.keyword}></td>
        <td><input name="keywords" type="text" value="<{$de.keywords}>" class="w350" /></td>
    </tr>
    
    <tr>
        <td>品牌</td>
        <td>
<input type="hidden" name="brand" id="brandid" value="<{if $de.brand}><{$de.brandid}>__<{$de.brand}><{/if}>"/>
                    <input style="width:350px;" type='text' id='brand' value="<{$de.brand}>" placeholder='输入品牌部分内容筛选' autocomplete="off"/>
            		<ul id="brandlist" style="display:none;position:absolute;background-color:#fff;border: 1px solid rgb(207, 201, 201);width: 150px;z-index:999;">
        			</ul>

</td>
    </tr>
    

    
    <tr>
        <td>上传图片</td>
        <td>
            <div class="product_image">
                <ul id="list1">
                    <{foreach item=list key=key from=$de.pic}>
                        <li id="p<{$key+1}>" data-itemid='<{$key+1}>'>
                            <div class="product_image_list">
                            	<div class="show_big"></div>
                                <div nc_type="handle_image">
                                    <div class="image">
                                    	
                                    <input name="pic[]" type="hidden" id="img<{$key}>" value="<{$list}>" />
                                    <{if $list}>
                                    <img id="img<{$key}>_img" src="<{$list}>" width="60">
                                    <{else}>
                                    <img width="60" id="img<{$key}>_img" src="<{$config.weburl}>/image/default/nopicsmall.gif"  />
                                    <{/if}>
                                    </div>
                                    <div nc_type="handle" class="bg">
                                    <span title="删除" nctype="delete_image">删除</span>
                                    </div>
                                </div>
																
                                <div class="upload-btn"><a class="upload-button" href="javascript:uploadfile('Style images','img<{$key}>',480,480,'product')">上传</a></div>
                            </div>
                        </li>
                    <{/foreach}>
                    <{assign var=count value=$de.pic|@count}>
                    <{section name=name loop=$count*-1+10}>
                        <li id="p<{$key+$smarty.section.name.index+1}>" data-itemid='<{$key+$smarty.section.name.index+1}>'>
                            <div nc_type="handle_image">
                                <div class="image">
                                    <input name="pic[]" type="hidden" id="pic<{$smarty.section.name.index}>" value="" />
                                    <img width="60" id="pic<{$smarty.section.name.index}>_img" src="<{$config.weburl}>/image/default/nopicsmall.gif"  />
                                </div>
                                <div nc_type="handle" class="bg">
                                <span title="删除" nctype="delete_image" class="delete">删除</span>
                                </div>
                            </div>
                            <div class="upload-btn"><a class="upload-button" href="javascript:uploadfile('Style images','pic<{$smarty.section.name.index}>',480,480,'product')">上传</a></div>
                        </li>
                    <{/section}>
                </ul>
            </div>
        </td>
    </tr>
    <tr>
        <td width="70">海关分类:</td>
        <td width="100">
         <select class="ws350" name='customs_cat'  id="customs_cat">
                <option value='0' rate="<{$de.tax_rate}>" hscode="<{$de.hscode}>">全部分类</option>
                <{foreach item=list from=$customs_cat}>
                
                <option value="<{$list.catid}>" rate="<{$list.tax_rate}>" hscode="<{$list.hscode}>" tax_paid_price="<{$list.tax_paid_price}>" <{if $de.hscode!='' and $list.hscode==$de.hscode}>selected<{/if}> <{if $list.scat}>disabled<{/if}>><{$list.cat}></option>
                   
                    <{foreach item=slist from=$list.scat}>
                    <option value="<{$slist.catid}>" rate="<{$slist.tax_rate}>" hscode="<{$slist.hscode}>" tax_paid_price="<{$slist.tax_paid_price}>" <{if $de.hscode!='' and $slist.hscode==$de.hscode}>selected<{/if}> <{if $slist.scat}>disabled<{/if}>>|__<{$slist.cat}></option>
                            
                            <{foreach item=lists from=$slist.scat}>
                            <option value="<{$lists.catid}>" rate="<{$lists.tax_rate}>" hscode="<{$lists.hscode}>" tax_paid_price="<{$lists.tax_paid_price}>" <{if $de.hscode!='' and $lists.hscode==$de.hscode}>selected<{/if}> <{if $lists.scat}>disabled<{/if}>>|____<{$lists.cat}></option>
                                <{foreach item=flist from=$lists.scat}>
                                <option value="<{$flist.catid}>" rate="<{$flist.tax_rate}>" hscode="<{$flist.hscode}>" tax_paid_price="<{$flist.tax_paid_price}>" <{if $de.hscode!='' and $flist.hscode==$de.hscode}>selected<{/if}> <{if $flist.scat}>disabled<{/if}>>|______<{$flist.cat}></option>
	                                <{foreach item=flists from=$flist.scat}>
	                                <option value="<{$flists.catid}>" rate="<{$flists.tax_rate}>" hscode="<{$flists.hscode}>" tax_paid_price="<{$flists.tax_paid_price}>" <{if $de.hscode!='' and $flists.hscode==$de.hscode}>selected<{/if}>>|________<{$flists.cat}></option>
	                                <{/foreach}>
                                <{/foreach}>
                            <{/foreach}>
                            
                    <{/foreach}> 
                    
                <{/foreach}> 
            </select>
            <input type="text" id="hscodeForSearch" placeholder="输入hscode搜索">
        </td>
    </tr>
    <tr>
        <td>税率</td>
        <td><input id="tax_rate" name="tax_rate" type="text" value="<{if $de.tax_rate}><{$de.tax_rate}><{/if}>" readonly/></td>
    </tr>
    
    <tr>
        <td>HSCODE</td>
        <td><input id="hscode" name="hscode" type="text" value="<{if $de.hscode}><{$de.hscode}><{/if}>" readonly/></td>
    </tr>
    <tr>
        <td>完税价</td>
        <td><input id="tax_paid_price" name="tax_paid_price" type="text" value="<{if $de.tax_paid_price}><{$de.tax_paid_price}><{/if}>" readonly/></td>
    </tr>
    
    <tr>
        <td>定价单位</td>
        <td><select name="unit"><option value="1">元</option></select></td>
    </tr>
    </tbody>
    </table>
    <table class="table" style="display:none;" id="default_sku_setting">
    
    <tbody>
    <tr>
        <td>默认SKU</td>
        <td class="property">
            <div>
            <table>
                <thead>
                <tr>
                    <td>销售价</td>
                    <td>分销价</td>
                    <td>红人分润比例</td>
                    <td>首席分润比例</td>
                    <td>市场指导价</td>
                    <td>申报价</td>
                    <td>库存</td>
                    <td>限购数量</td>
                </tr> 
                </thead>
                <tbody>
                <tr><td><input type="text" name="price" id="price" class="text"  value="<{if $de.price}><{$de.price}><{else}>0.00<{/if}>" /></td>
                	<td>  <input type="text" name="dis_price" id="dis_price" class="text" value="<{if $de.dis_price}><{$de.dis_price}><{else}>0.00<{/if}>" /> </td>
                	<td>  <input type="text" name="distribution" id="distribution" class="text" value="<{if $de.distribution}><{$de.distribution}><{else}>0.00<{/if}>" />  %</td>
                	<td>  <input type="text" name="distribution1" id="distribution1" class="text" value="<{if $de.distribution1}><{$de.distribution1}><{else}>0.00<{/if}>" />  %</td>
                	<td>  <input type="text" name="market_price" id="market_price" class="text" value="<{if $de.market_price}><{$de.market_price}><{else}>0.00<{/if}>" /></td>
                	<td>  <input type="text" name="declared_price" id="declared_price" class="text" value="<{if $de.declared_price}><{$de.declared_price}><{else}>0.00<{/if}>" /> </td>
                	<td><input type="text" value="<{$de.stock}>" disabled style="background:#E7E7E7;" class="text"/></td>
                	<td> <input id="buy_limit" name="buy_limit" type="text" class="text" value="<{$de.buy_limit|default:1}>" stock="<{$de.buy_limit}>"/></td></tr>

                </tbody>
            </table>
            </div>
        </td>
    </tr>        
    </tbody>
    
    </table>
    <{if $firstvalue.d.0}>
    <table class="table"  id="spec">
    <thead>
    <tr>
        <th colspan="2" class="partition">销售属性</th>
    </tr>
    </thead>
    
    <tbody class="firstvalue">
    <{foreach item=list key=num from=$firstvalue.d}>
    <tr <{if $list.ignore}>style="background:#eee;"<{/if}>>
        <td><p><{$list.name}></p>
        <p><input type="checkbox" style="margin-top:8px;" onclick="ignore_property('property_td_<{$num}>',this)" ignore_type="property_td_<{$num}>" <{if $list.ignore}><{else}>checked<{/if}>></p>
        </td>
        <td nc_type="property_td_<{$num}>" class="property">
            <ul class="property_ul" <{if $list.field=='color'}>id="color"<{/if}>>
                <{$list.item}>
            </ul>
            <div class="clear"></div>
            <{if $list.field=='color'}>
                <table cellpadding="0" cellspacing="0" nc_type="color_img" style="display:none">
                    <thead>
                    <tr>
                        <td><{$list.name}></td>
                        <td width="200">选择头图图片（无图片可不选）</td>
                        <td width="100">已有图片</td>
                    </tr>
                    </thead>
                    <tbody>
                    <{foreach item=clist key=key from=$firstvalue.d}>
                    <{if $clist.field=='color'}>
                    <{foreach item=slist key=num from=$clist.color}>
                        <tr id="color_img_tr_<{$num}>" style="display:none">
                            <td><{$slist.name}></td>
                            <td align="center">
                            <input name="color_img[<{$key}>_<{$num}>]" type="hidden" id="color_img<{$num}>" value="<{$slist.img}>" /> 
                            <a class="upload-button" href="javascript:choose_pic('color_img<{$num}>')">选择</a>
                            
                            </td>
                            <td>
                            <img align="absmiddle" id="color_img<{$num}>_img" class="imgs" src="<{if $slist.img}><{$slist.img}><{else}>../image/default/user_admin/transparent.gif<{/if}>" />
                            
                            <span id="color_img<{$num}>_del" del_id="color_img<{$num}>"><{if $slist.img}><a href="javascript:;">(删)</a><{else}>(无)<{/if}></span>
                            
                            </td>
                        </tr>
                    <{/foreach}>
                    <{/if}>
                    <{/foreach}>
                    </tbody>
                </table>
            <{/if}>
        </td>
    </tr>
    <{/foreach}>
    </tbody>
    
    <tbody nc_type="property_tbody" style="display:none">
    <tr>
        <td>SKU设置</td>
        <td class="property">
            <div>
            <table>
                <thead>
                <tr>
                    <{foreach item=list key=num from=$firstvalue.d}>
                    <td><{$list.name}></td>
                    <{/foreach}>
                    <td>SKU</td>
                    <td>销售价</td>
                    <td>分销价</td>
                    <td>红人分润比例</td>
                    <td>首席分润比例</td>
                    <td>市场指导价</td>
                    <td>申报价</td>
                    <td>库存</td>
                    <td>限购数量</td>
                    <td>物流重量(千克)</td>
                </tr> 
                </thead>
                <tbody nc_type="property_table"></tbody>
            </table>
            </div>
        </td>
    </tr>        
    </tbody>
    </table>
    
    <{/if}>
    
    
    
    <{if $firstvalue.s.0}>
    <table class="table" id="other">
    <thead>
    <tr>
        <th colspan="2" class="partition">其它属性</th>
    </tr>
    </thead>
    
    <tbody>
    <{foreach item=list key=num from=$firstvalue.s}>
        <{$list}>
    <{/foreach}>
    <tr>
        <td colspan="99" class="height"></td>
    </tr>
    </tbody>   
    </table>
    <{/if}>
    
    <{if $firstvalue.p}>
    <table class="table" id="parameter">
    <thead>
    <tr>
        <th colspan="2" class="partition">详细参数</th>
    </tr>
    </thead>
    
    <tbody>
    <{foreach item=list key=num from=$firstvalue.p}>
        <tr><td width="100"><{$num}></td></tr>
        <{foreach item=slist key=key from=$list}>
            <{$slist}>
        <{/foreach}>
    <{/foreach}>
    <tr>
        <td colspan="99" class="height"></td>
    </tr>
    </tbody>   
    </table>
    <{/if}>
     <{if $allextfield}>
    <table class="table" id="other">
    <thead>
    <tr>
        <th colspan="2" class="partition">扩展字段</th>
    </tr>
    </thead>
    
    <tbody>
    <{foreach item=list key=num from=$allextfield}>
        <{$list}>
    <{/foreach}>
    <tr>
        <td colspan="99" class="height"></td>
    </tr>
    </tbody>   
    </table>
    <{/if}>
    
    <table class="table" id="detail">
    <thead>
    <tr>
        <th colspan="2" class="partition">商品详情</th>
    </tr>
    </thead>
    
    <tbody>
    <tr>
        <td colspan="2" class="detail">
        <script charset="utf-8" src="<{$config.weburl}>/lib/kindeditor/kindeditor-min.js"></script>
        <script>
            var editor;
            KindEditor.ready(function(K) {
                editor = K.create('textarea[name="detail"]', {
                langType :'<{$config.language}>'
            });
        });
        </script>
        <textarea name="detail" id="detail" style="width:100%; height:400px;"><{$de.detail}></textarea>
        </td>
    </tr>
    </tbody>
    </table>
    <table class="table" id="logistics">
    <thead>
    <tr>
        <th colspan="2" class="partition">物流信息</th>
    </tr>
    </thead>
    
    <tbody>
    	
			<tr>
        <td width="100">发货仓库</td>
        <td>
                <select id="stock_shop" name="stock_shop" onchange="$('#shop_img_logo').attr('src','<{$config.weburl}>/image/admin/'+$(this).val()+'.png')">
                <option value="">----请选择----</option>
								<{foreach from=$stock_shops key=key item=item}>
									<option value="<{$item.id}>" <{if $de.stock_shop==$item.id}>selected<{/if}>><{$item.show_title}></option>
								<{/foreach}>
               </select>
							 <{if $de.stock_shop}><img src="<{$config.weburl}>/image/admin/<{$de.stock_shop}>.png" width="24" height="24" style="vertical-align:top;" id="shop_img_logo"><{/if}>
            </div>
        </td>
    </tr>
    <tr>
        <td width="100">可送区域</td>
        <td>
            <input type="hidden" name="t" id="t" value="<{$de.area|default:"全国"}>" />
            <input type="hidden" name="province" id="id_1" value="<{$de.province}>" />
            <input type="hidden" name="city" id="id_2" value="<{$de.city}>" />
            <input type="hidden" name="area" id="id_3" value="<{$de.areaid}>" />
            <{if $de.area}>
            <div id="d_1"><{$de.area}>&nbsp;&nbsp;<a href="javascript:sd();">编辑</a></div>
            <{/if}>
            <div id="d_2" <{if $de.area}>class="hidden"<{/if}>>
                <select id="select_1" onChange="selClass(this);">
                <option value="">--请选择--</option>
                <option value="0">全国</option>
                <{$prov}>
                </select>
                <select id="select_2" onChange="selClass(this);" class="hidden"></select>
                <select id="select_3" onChange="selClass(this);" class="hidden"></select>
            </div>
        </td>
    </tr>
    <tr>
        <td width="100">所在地</td>
        <td>
            <div>
                <select name="province1" id="province1">
                    <option value="0">--请选择--</option>
                    <{foreach item=list key=num from=$district_list}>
                        <option value="<{$list.provinceID}>">--<{$list.province}>--</option>
                    <{/foreach}>
                </select>
            </div>
        </td>
    </tr>

    
    <tr>
        <td>物流重量(千克)</td>
        <td><input value="<{if $de.weight}><{$de.weight}><{else}>0<{/if}>" id="weight" name="weight" type="text" /><a href="javascript:;" nc_type="set_weight">设置SKU重量</a></td>
    </tr>
    
    <tr>
        <td>物流体积(立方米)</td>
        <td><input value="<{if $de.cubage}><{$de.cubage}><{else}>0<{/if}>" id="cubage" name="cubage" type="text" /></td>
    </tr>
    
    <tr>
        <td>备货期</td>
        <td>
        <input value="<{$de.waiting_time}>" id="waiting_time" name="waiting_time" type="text" />-
        <input value="<{$de.waiting_time_end}>" id="waiting_time_end" name="waiting_time_end" type="text" />天发货
        </td>
    </tr>
    
    <tr>
        <td colspan="99" class="height"></td>
    </tr>
    </tbody>
    </table>
  <!--   <table class="table" id="parts">
    <thead>
    <tr>
        <th colspan="2" class="partition">推荐组合商品</th>
    </tr>
    </thead>
    
    <tbody>
    <tr>
        <td colspan="99" class="colspan">
            <table width="100%" class="alc">
               	<tr id="parts_tr" <{if !$de.product_partss}> style="display:none"<{/if}>>
                    <th class="al">产品名称</th>
                    <th width="100">产品编号</th>
                    <th width="100">销售价</th>
                    <th width="100">市场价</th>
                    <th width="100">成本价</th>
                    <th width="100">库存</th>
                    <th width="100"></th>
                </tr>
                <{foreach item=slist from=$de.product_partss}>
                <{foreach item=list from=$slist}>
                <tr>
                    <td class="al"><{$list.pname}></td>
                    <td><{$list.code}></td>
                    <td><{$list.price}></td>
                    <td><{$list.show_price}></td>
                    <td><{$list.cost_price}></td>
                    <td stock="<{$list.amount}>"></td>
                    <td><div><a href="javascript:;" class="deleterow" onClick="deleterow(this,<{$list.id}>,'related')">删除</a></div></td>
                </tr>
                <{/foreach}>
                <{/foreach}>
                <tr>
                    <td colspan="99" class="al">
                        <a class="addtr" id="parts_button" nc_type="parts" href="javascript:void();">添加推荐组合</a>
						<input type="hidden" id="hidden_parts" name="product_parts" value="<{if $de.product_parts}><{$de.product_parts}>,<{else}>0,<{/if}>" />
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    </tbody>
    </table>
    <table class="table" id="give">
    <thead>
    <tr>
        <th colspan="2" class="partition">赠送产品</th>
    </tr>
    </thead>
    
    <tbody>
    <tr>
        <td colspan="99" class="colspan">
            <table width="100%" class="alc">
               <tr id="give_tr" <{if !$de.product_gives}> style="display:none"<{/if}>>
                    <th class="al">产品名称</th>
                    <th width="100">产品编号</th>
                    <th width="100">销售价</th>
                    <th width="100">市场价</th>
                    <th width="100">成本价</th>
                    <th width="100">库存</th>
                    <th width="100"></th>
                </tr>
                <{foreach item=slist from=$de.product_gives}>
                <{foreach item=list from=$slist}>
                <tr>
                    <td class="al"><{$list.pname}></td>
                    <td><{$list.code}></td>
                    <td><{$list.price}></td>
                    <td><{$list.show_price}></td>
                    <td><{$list.cost_price}></td>
                    <td stock="<{$list.amount}>"></td>
                    <td><div><a href="javascript:;" class="deleterow" onClick="deleterow(this,<{$list.id}>,'related')">删除</a></div></td>
                </tr>
                <{/foreach}>
                <{/foreach}>
                <tr>
                    <td colspan="99" class="al">
                    <a class="addtr" id="give_button" nc_type="give" href="javascript:void();">赠送产品</a>
                       <input type="hidden" id="hidden_give" name="product_give" value="<{if $de.product_give}><{$de.product_give}>,<{else}>0,<{/if}>" />
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    </tbody>
    </table>  -->
    <table class="table" id="related">
    <thead>
    <tr>
        <th colspan="2" class="partition">相关产品</th>
    </tr>
    </thead>
    
    <tbody>
    <tr>
        <td colspan="99" class="colspan">
            <table width="100%" class="alc">
                <tr id="related_tr" <{if !$de.product_relateds}> style="display:none"<{/if}>>
                <th width="100">产品ID</th>
                    <th class="al">产品名称</th>
                    <th width="100">产品编号</th>
                    <th width="100">产品分类</th>
                    <th width="100">产品标签</th>
                    <th width="100">品牌</th>
                    <th width="100">销售价</th>
                    <th width="100">市场价</th>
                    <th width="100"></th>
                </tr>
                <{foreach item=list from=$de.product_relateds}>
                <tr>
                		<td><{$list.id}></td>
                    <td class="al"><{$list.pname}></td>
                    <td><{$list.code}></td>
                    <td><{$list.catname}></td>
                    <td><{$list.tags}></td>
                    <td><{$list.brand}></td>
                    <td><{$list.price}></td>
                    <td><{$list.market_price}></td>
                    <td><div><a href="javascript:;" class="deleterow" onClick="deleterow(this,<{$list.id}>,'related')">删除</a></div></td>
                </tr>
                <{/foreach}>
                <tr>
                    <td colspan="99" class="al">
                    <a class="addtr" id="related_button" nc_type="related" href="javascript:void();">相关产品</a>
                    <input type="hidden" id="hidden_related" name="product_related" value="<{if $de.product_related}><{$de.product_related}>,<{else}>0,<{/if}>" />
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    </tbody>
    </table>   
    <table>
    <tr>
        <td colspan="2" style="border-top:1px dotted #DEEFFB;">
            <input type="submit" value="<{$lang.submit}>" class="submit" onClick="$('#returnself').val(0);"/>
            <!---->
            <input type="submit" value="应用" class="submit" onClick="$('#returnself').val(1);"/>
            <input type="hidden" name="returnself"  value="0" id="returnself"/>
            <!---->
            <{if $de.status==0|| $de.status==-1}>
            <input type="submit" value="送审" class="submit" onClick="$('#tocheck').val(1);"/>
            <input type="hidden" name="tocheck"  value="0" id="tocheck"/>
            <{/if}>
            <input name="submit" type="hidden" value="<{if $de.id}>edit<{else}>submit<{/if}>" />
            <input name="editID" type="hidden" id="editID" value="<{$de.id}>" />
            <input type="hidden" name="statu" value="<{$de.status}>" />
            <input type="hidden" name="freightcon" value="0" />
            <input type="hidden" name="custom_cat" value="0" />
            <input type="hidden" name="rec_pro" value="0" />
            <input type="hidden" name="ptype" value="0" />
             <input type="hidden" name="property_id" value="<{$property_id}>" />
        </td>
    </tr>
    </table>
</form>
</div>
</body>
</html>
<script language="javascript" src="<{$config.weburl}>/script/product.js"></script>
<script language="javascript" src="<{$config.weburl}>/script/jquery.dragsort-0.5.1.min.js"></script>
<script type="text/javascript">
/*
$.getJSON('<{$config.weburl}>/admin/module.php?m=inventory&s=classes.php&uri=api',function(data){
	//alert(data);
	$.each(data,function(key,item){
		$('#classes').append('<option value="'+item.id+'">'+item.title+'</option>');
		if(item.children){
			$.each(item.children,function(k,v){
				$('#classes').append('<option value="'+v.id+'">|——'+v.title+'</option>');

			})
		}
	})
})*/


/* 
function setinventory(spec){
	if(parent.$data){
	}else{
		alert('库存设置失败，请重试');	return false;
	}
	

	
		var d=spec!="0"?parent.$data[spec]:parent.$data.inventory;
		var total=0;
		var stock=0;
		var totalprice=0;
		var arr=[];
		//$('#stock').val(d);
		$.each(d,function(k,v){
			if(v){
				v.stocks=parseFloat(v.stocks);
			if(stock==0){
				stock=v.stocks;
			}else if(stock>v.stocks){
				//alert(stock)
					stock=v.stocks;
				}
			total+=parseInt(v.nums);
			totalprice+=v.nums*v.pricesell;
			
			arr.push(v.id+'_'+v.nums);
			
			}
		});
		totalprice=totalprice.toFixed(2);
	if(spec!=0){
		$('input[nc_type="'+spec+'|price"]').val(totalprice);
		$('input[nc_type="'+spec+'|show_price"]').val(totalprice);
		$('input[nc_type="'+spec+'|cost_price"]').val(totalprice);
		$('input[nc_type="'+spec+'|amount"]').val(stock);
		$('input[nc_type="'+spec+'|stock"]').val(arr.join(','));
		count_price('price');
		count_price('show_price');
		count_price('cost_price');
		count_price('market_price');
		
	}else{
		$('#stock').val(arr.join(','));
		$('input[name="price"]').val(totalprice);
		$('input[name="show_price"]').val(totalprice);
		$('input[name="cost_price"]').val(totalprice);
		$('#amount').val(stock);
		$('#inventorynum').html(total);
	}
} */


/* $('#clearinventory').click(function(){
	if(confirm('确认删除？')){
	$('input[name="price"]').attr('readonly','readonly').css('background','#E7E7E7 none').val('0.00');
	$('input[name="show_price"]').attr('readonly','readonly').css('background','#E7E7E7 none').val('0.00');
	$('input[name="cost_price"]').val('0.00');
	$('#amount').val(0);
	$('#inventorynum').html(0);
	$('#stock').val('');
		parent.$data.inventory={};
	}
	
})
 */

$('.addtr').live('click',function(){
	type=$(this).attr('nc_type');
	spec=$(this).attr('spec')||0;
	if(type=='inventory'){
		title="选择库存商品";
		window.parent.iframe_form(type,title,'<{$config.weburl}>/admin/module.php?m=product&s=inventory_list.php&type='+type+'&spec='+spec, 800, 505);
		return false;
	}
	
	if(type=='parts') title="选择添加配件";
	if(type=='give') title="选择赠送产品";
	if(type=='related') title="选择相关产品";
	window.parent.iframe_form(type,title,'<{$config.weburl}>/admin/module.php?m=product&s=product_list.php&id=<{$de.id}>&type='+type, 800, 505);
	return false;
	});

$('.itemtitle ul li').unbind().each(function(){
	$(this).click(function(){
		id=$(this).children().attr('id');
		$(this).addClass("current").siblings().removeClass("current");	
		if(id=='base')
			$(".container").find("table").removeClass("hidden");
		else
			$(".container").find("#"+id).removeClass("hidden").siblings(".table").addClass("hidden");	
	});
});

var rowtypedata = [
	[
		[1, ''], 
		[1, '', 'al'], 
		[1, ''], 
		[1, ''], 
		[1, ''], 
		[1, ''],
		[1, ''],
		[1, ''],
		[1, '<div><a href="javascript:;" class="deleterow" onClick="deleterow(this,{1})">删除</a></div>']
	
	]
];
var addrowdirect = 0;
var addrowkey = 0;
function addrow(name, type) {
	
	$('#'+name+'_tr').show();
	var obj=$('#'+name+'_button')[0];	
	var table = obj.parentNode.parentNode.parentNode.parentNode;
	var iframe=window.parent.document.getElementById("iframe_"+name).contentWindow;
	var tab=iframe.document.getElementById(name+"_table");
	var checkbox= $(tab).find("input[class='checkitem']:checked");
	var typedata = rowtypedata[type];
	$.each(checkbox,function(i){
		var value1=$("#hidden_"+name).val();
		var value2=this.value
		if(value1.indexOf(','+value2+',') <= 0 )
		{
			$("#hidden_"+name).val(value1+value2+',');	
			var tr=$(this).parent().parent();
			if(!addrowdirect) {
				var row = table.insertRow(obj.parentNode.parentNode.rowIndex);
			} else {
				var row = table.insertRow(obj.parentNode.parentNode.rowIndex + 1);
			}
			for(var i = 0; i <= typedata.length - 1; i++) {
				if(i<=8)
				{
					var cell = row.insertCell(i);
					if(i==8)
					{
						var tmp = typedata[i][1];
					}
					else
					{
						var tmp = tr.find('td')[i+1].innerHTML;
					}
					if(i==1){
						cell.className = typedata[i][2];
					}
					tmp = tmp.replace(/\{(n)\}/g, function($1) {return addrowkey;});
					tmp = tmp.replace(/\{(\d+)\}/g, function($1, $2) { return value2+',\''+name+'\''; });
					cell.innerHTML = tmp;
				}
			}
			addrowkey ++;
			addrowdirect =0;
		}
	});
}

function deleterow(obj,id,name) {
	var table = obj.parentNode.parentNode.parentNode.parentNode.parentNode;
	var tr = obj.parentNode.parentNode.parentNode;
	var value=$("#hidden_"+name).val();

	var pattern = ','+id+',';
	str = value.replace(new RegExp(pattern), ",");
	$("#hidden_"+name).val(str);
	table.deleteRow(tr.rowIndex);
}

$("#list1").dragsort({ dragSelector: "div", dragSelectorExclude:"span",dragBetween: true, dragEnd: saveOrder, placeHolderTemplate: "<li class='placeHolder'><div></div></li>" });

function saveOrder()
{
	var data = $("#list1 li").map(function() { return $(this).data("itemid"); }).get();
};

function check_value()
{
	if(!document.getElementById('title').value)
	{
		alert('<{$lang.notice_title}>');
		document.getElementById('title').focus();
		return false;
	}
	if(document.getElementById('catid').value=='')
	{
		alert('<{$lang.product_category}>');
		return false;
	}
	if($('#brandid').val()==''){
		alert('请选择品牌');
		$('#brand').focus();
        return false;
	}
    if(($('#tax_rate').val()<=0) || ($('#hscode').val()=='')){
    	alert('请选择海关分类');
        $('#customs_cat').focus();
        return false;
    }
	if(parseFloat($('#price').val())>0)
	{
		var pr = $('#price').val();
		var mpr=$('#market_price').val();
		var dpr=$('#dis_price').val();
		var dcpr=$('#declared_price').val();
		
		if(pr.length>10||!pr.match(/^(:?(:?\d+.\d+)|(:?\d+))$/))
		{
			alert('产品价格错误');
			$('#price').focus();
			return false;
		}
		if(mpr.length>10||!mpr.match(/^(:?(:?\d+.\d+)|(:?\d+))$/))
		{
			alert('指导价格错误');
			$('#market_price').focus();
			return false;
		}
		if(dpr.length>10||!dpr.match(/^(:?(:?\d+.\d+)|(:?\d+))$/))
		{
			alert('分销价格错误');
			$('#dis_price').focus();
			return false;
		}
		if(dcpr.length>10||!dcpr.match(/^(:?(:?\d+.\d+)|(:?\d+))$/))
		{
			alert('申报价格错误');
			$('#declared_price').focus();
			return false;
		}
		if(parseFloat(pr)>parseFloat(mpr)){
			alert('指导价不能小于销售价');
            $('#market_price').focus();
            return false;
		}
		if(parseFloat(dpr)>parseFloat(pr)){
			alert('分销价不能大于销售价');
            $('#dis_price').focus();
            return false;
		}
		if(parseFloat(dcpr)>parseFloat(pr)){
			 if(!confirm('申报价大于销售价是否保存？')){
              $('#declared_price').focus();
              return false;
             }
		}
	}
	else
	{	
		alert('请填写产品价格');
		$('#price').focus();
		return false;
	}
	
	
	if(parseFloat($('#dis_price').val())<=0)
	{
		alert('请填写产品分销价格');
		$('#dis_price').focus();
		return false;
	}
	if(parseFloat($('#declared_price').val())<=0)
	{
		alert('请填写产品申报价格');
		$('#declared_price').focus();
		return false;
	}
	
	
	if(!$('#stock_shop').val()){
		alert('请选择发货仓库');
        return false;
	}
    if(!$('#province1').val()){
		alert('所在地');
        return false;
	}
	
	if(!(parseFloat($('#weight').val())>0)){
		alert('请填写重量');
        return false;
	}
	if($('#tags').val()==null){
		alert('请选择标签');
        return false;
	}
	
	var w_time = $('#waiting_time').val();
	var w_time_end = $('#waiting_time_end').val();
	w_time = w_time?w_time:0;
	w_time_end = w_time_end?w_time_end:0;
	if(parseInt(w_time) > parseInt(w_time_end)){
		alert('请正确填写备货期');
        $('#waiting_time_end').focus();
        return false;
	}
/*	if($('#amount').val()=='')
	{
		alert('请填写库存数量');
		document.getElementById('amount').focus();
		return false;
	}*/
	
	/* if($('#id_3').val()=='')
	{
		alert('请选择产品所在区域');
		return false;
	} */
	var sku_setting=true;
	$('input[ignore_type]:checked').each(function(){
		
		if($('td[nc_type="'+$(this).attr('ignore_type')+'"]').find('input[type="checkbox"]:checked').size()==0){
			sku_setting=false;
			return false;
		}
	});
	if(!sku_setting){
		alert('请至少选择一个销售属性');
		return false;
	}
	
	
}
function load_pic()
{
	

	
	$.getScript("<{$config.weburl}>/script/product.js",function(){
			$('[nc_type="handle_image"]').each(function(){
				
		if(!$(this).find(':input').val()){
			
			return true;
		}
		else if($(this).parent().find('.show_big').size()){
			return true;
		}
		else{
			var $d=$('<div class="show_big"></div>').hover(function(){
				var _left=$(this).offset().left;
				var _top =$(this).offset().top;
				var $$=$(this).next().find('img').attr('src');
				$('<img id="biger_img" width="300" height="300" style="position:absolute;z-index:999;left:'+(_left-(-11))+'px;top:'+(_top-(-11))+'px;"/>').attr('src',$$).appendTo($(document.body));
			},function(){
				$('#biger_img').remove();
			})
			$(this).before($d);
		}
	});
	});
}

/*-------------销售属性------------------*/
var property_checked = [<{foreach item=list key=num from=$firstvalue.d}><{if $num+1==$firstvalue.d|@count}>''<{else}>'',<{/if}><{/foreach}>];
var str = '';
var property_color;
var V = new Array();
<{foreach item=list key=num from=$firstvalue.d}>
var property_checked_<{$num}> = new Array();
<{if $list.field=='color'}>
 property_color=<{$num}>;
<{/if}>
<{/foreach}>

$(function(){
	/************zx************/
	$('input[name=code]').css('background','#E7E7E7 none');
	
	/* $('input[name="amount"]').attr('readonly','readonly').css('background','#E7E7E7 none');
	
	$('input[name="price"]').attr('readonly','readonly').css('background','#E7E7E7 none');
	$('input[name="show_price"]').attr('readonly','readonly').css('background','#E7E7E7 none');
	$('input[name="cost_price"]').attr('readonly','readonly').css('background','#E7E7E7 none'); */

	/*************zx****************/
	
	
	
	$('tbody[nc_type="property_table"]').find('input[type="text"]').live('change',function(){
		s = $(this).attr('nc_type');
		V[s] = $(this).val();
	});
	$('span[nc_type="chk"] > input[type="checkbox"]').click(function(){
		into_set();
	});
	$('span[nc_type="chk"] > input[type="checkbox"]').click(function(){
		stock_set();
	});
	
	
	$('a[nc_type="set_weight"]').click(function(){
		
		weight_set();
		
	})
	
	$('input[data_type="stock"]').live('change',function(){
		//count_stock();
	});
	$('input[data_type="sku"]').live('change',function(){
		//code();
	});
	$('input[data_type="price"]').live('change',function(){
		count_price('price');
		count_price('dis_price');
	});
	$('input[data_type="dis_price"]').live('change',function(){
		count_price('price');
		count_price('dis_price');
	});
	$('input[data_type="declared_price"]').live('change',function(){
		count_price('declared_price');
	});
	$('input[data_type="market_price"]').live('change',function(){
		count_price('market_price');
	});
	$('#color').find('input[type="checkbox"]').click(function(){
		pic_show($(this));
	});
	
	$('input[type="submit"]').click(function(){
		$('input[data_type="price"]').each(function(){
			if($(this).val() == ''){
				$(this).val($('input[name="price"]').val());
			}
		});
		$('input[data_type="stock"]').each(function(){
			if($(this).val() == ''){
				$(this).val('0');
			}
		});
		if($('dl[nc_type="property_tbody"]').css('display') == 'none'){
			$('dl[nc_type="property_tbody"]').find('input').attr('disabled','disabled');
		}
	});
	
});

function into_set(){
	
	<{foreach item=list key=num from=$firstvalue.d}>
	property_checked_<{$num}> = new Array();
	
	if($('input[type="checkbox"][ignore_type="property_td_<{$num}>"]').is(':checked')){
	$('td[nc_type="property_td_<{$num}>"]').find('input[type="checkbox"]:checked').each(function(){
		v = $(this).attr('nc_type');
		i = $(this).val();
	
		property_checked_<{$num}>[property_checked_<{$num}>.length] = [v,i];
	});
	}else if($('input[ignore_type]:checked').size()>0){
		property_checked_<{$num}>[0] = ['-',0];
	}
	property_checked[<{$num}>] = property_checked_<{$num}>;
	<{/foreach}>

}


function ignore_property(property,obj){
	
	if($('#editID').val()>0?confirm('调整销售属性会重置所有sku，确认？'):1){
	
	if($(obj).is(':checked')){
		$(obj).parents('tr:eq(0)').css('background','none');
		$('td[nc_type="'+property+'"]').find('input[type="checkbox"]').removeAttr('disabled');
	}else{
		$('#color').find('input[type="checkbox"]:checked').each(function(){
			$(this).removeAttr('checked');
			pic_show($(this));
		});
		$('td[nc_type="'+property+'"]').find('input[type="checkbox"]:checked').removeAttr('checked');

		into_set();stock_set();
		$(obj).parents('tr:eq(0)').css('background','#eee');
		$('td[nc_type="'+property+'"]').find('input[type="checkbox"]').attr('disabled','disabled');


	}
	
	}else{
		if($(obj).is(':checked')){
			$(obj).removeAttr('checked');
		}else{
			$(obj).attr('checked','checked');

		}
	}
}

function weight_set(){
	
	if($('tbody[nc_type="property_table"]').is(':hidden')){
		return;
	}
	
	var wt=$('#weight').val();
	
	$('table[id=spec]').find('input').eq(0).focus();
	$('input[data_type="weight"]').attr('readonly','').css('background','').each(function(){
		if(!parseFloat($(this).val())){
			$(this).val(wt);
		}
		
	}).eq(0).focus();
}



function stock_set(){
	
	/* $('input[name="price"]').attr('readonly','readonly').css('background','#E7E7E7 none');
	$('input[name="show_price"]').attr('readonly','readonly').css('background','#E7E7E7 none');
	$('input[name="cost_price"]').attr('readonly','readonly').css('background','#E7E7E7 none'); */
	$('input[name="code"]').attr('readonly','readonly').css('background','#E7E7E7 none');
	
	$('tbody[nc_type="property_tbody"]').show();
	$('#default_sku_setting').hide();
	str = '<tr>';
		
	<{$abc}>
	
	if(str == '<tr>'){
		//$('input[name="price"]').attr('readonly','').css('background','');
		//$('input[name="show_price"]').attr('readonly','').css('background','');
		//$('input[name="cost_price"]').attr('readonly','').css('background','');
		//$('input[name="amount"]').attr('readonly','').css('background','');
		//$('input[name="code"]').attr('readonly','').css('background','');
		$('tbody[nc_type="property_tbody"]').hide();
		$('#default_sku_setting').show();
	}
	
	var i=0;
	$('tbody[nc_type="property_table"]')
		.empty()
		.html(str)
		.find('input[type="text"]').each(function(){
			s = $(this).attr('nc_type');
			try{
                $(this).val(V[s])}catch(ex){$(this).val('')};
			if($(this).attr('data_type') == 'price' && $(this).val() == ''){
				$(this).val($('input[name="price"]').val());
			}
            if($(this).attr('data_type') == 'distribution' && $(this).val() == ''){
                $(this).val($('input[name="distribution"]').val());
            }
                if($(this).attr('data_type') == 'distribution1' && $(this).val() == ''){
                    $(this).val($('input[name="distribution1"]').val());
                }
			if($(this).attr('data_type') == 'dis_price' && $(this).val() == ''){
				$(this).val($('input[name="dis_price"]').val());
			}
			if($(this).attr('data_type') == 'declared_price' && $(this).val() == ''){
				$(this).val($('input[name="declared_price"]').val());
			}
			if($(this).attr('data_type') == 'market_price' && $(this).val() == ''){
				$(this).val($('input[name="market_price"]').val());
			}
			if($(this).attr('data_type') == 'sku' && $(this).val() == ''){
				$(this).val('添加商品自动生成');
			}
			if($(this).attr('data_type') == 'buy_limit' && $(this).val() == ''){
				$(this).val($('input[name="buy_limit"]').val());
			}
		});
	//count_stock();
	count_price('price');
	count_price('dis_price');
	count_price('declared_price');
	count_price('market_price');
	//code();
}

function count_stock(){
	var stock = 0;
	$('input[data_type="stock"]').each(function(){
		if($(this).val() != ''){
			stock += parseInt($(this).val());
		}
	});
	$('input[name="amount"]').val(stock);
}

function code(){
	var max = 0.01;
	var min = 10000000;
	$('input[data_type="sku"]').each(function(){
		if($(this).val() != ''){
			max = Math.max(max,$(this).val());
			min = Math.min(min,$(this).val());
		}
	});
	if($('input[name="code"]').val()!='0' && !$('input[name="code"]').val())
	{
		if(min != 10000000){
			$('input[name="code"]').val(min);
		}
	}
}

function count_price(obj){
	var max = 0.01;
	var min = 10000000;
	$('input[data_type="'+obj+'"]').each(function(){
		if($(this).val() != ''){
			max = Math.max(max,$(this).val());
			min = Math.min(min,$(this).val());
		}
	});
	if(min != 10000000){
		$('input[name="'+obj+'"]').val(min.toFixed(2));
	}
}

function pic_show(Obj){
	var V = $('#color').find('input[type="checkbox"]:checked');
	if(V.length == 0){	
		$('table[nc_type="color_img"]').hide();
	}else{
		$('table[nc_type="color_img"]').show();
	}
	var S = $('tr[id="color_img_tr_'+Obj.val()+'"]');
	if(S.css('display') == 'none'){
		S.show();
	}else{
		S.hide();
	}
}


function choose_pic(obj)
{	
	var pic_info='';
	
	$.each($(":input[name='pic\[\]']"),function(k,v){
		if(!$(v).val())return;
		//alert($(v).val());
		pic_info+='<li><div class="image"><img src="'+$(v).val()+'" width="60"></div><div class="upload-btn" style="cursor: pointer;"><a href="javascript:;" chose_pic="'+$(v).val()+'" class="upload-button">设为首图</a></div></li>';
		
	});
	
	if(pic_info==''){
		pic_info='<li>无可选图片，<br/>请先上传</li>';
	}
	
	
	
	alertWin('选择图片', '<div class="product_image"><ul>'+pic_info+'</ul></div>',650, 330);
	$('[chose_pic]').click(function(){
		//alert(obj);
		$('#'+obj).val($(this).attr('chose_pic'));
		$('#'+obj+'_img').attr('src',$(this).attr('chose_pic'));
		$('#'+obj+'_del').html('<a href="javascript:;">(删)</a>');
		close_win();
	})
}

$(function(){
	$('[del_id]').each(function(){ 
		var $span=$(this);var delid=$span.attr('del_id');
		$(this).find('a').live('click',function(){
			//alert($del_id);
			$span.html('(无)');
			$('#'+delid).val('');
			$('#'+delid+'_img').attr('src','../image/default/user_admin/transparent.gif');
		})
		
	})
	$('.imgs[id^=color_img]').live('hover',function(event){
			if(event.type=='mouseenter'){
				var _left=$(this).offset().left;
				var _top =$(this).offset().top;
				var $$=$(this).attr('src');
				$('<img id="biger_img" width="300" height="300" style="position:absolute;z-index:999;left:'+(_left-(-15))+'px;top:'+(_top-(-15))+'px;"/>').attr('src',$$).appendTo($(document.body));
			}else{
				$('#biger_img').remove();
			}
}) 
	
	
	
});


$(function(){
	var E_SP = new Array();
	var E_SPV = new Array();
	<{foreach item=list from=$de.porperty}>
		<{foreach item=slist from=$list.setmeal}>
				<{foreach item=val key=num from=$slist}>
					E_SP[<{$num}>] = '<{$val}>';
					<{/foreach}>
						<{/foreach}>	
			E_SPV['i_<{$list.property_value_id}>|price'] = '<{$list.price}>';
			E_SPV['i_<{$list.property_value_id}>|dis_price'] = '<{$list.dis_price}>';
			E_SPV['i_<{$list.property_value_id}>|distribution'] = '<{$list.distribution}>';
			E_SPV['i_<{$list.property_value_id}>|distribution1'] = '<{$list.distribution1}>';
			E_SPV['i_<{$list.property_value_id}>|declared_price'] = '<{$list.declared_price}>';
			E_SPV['i_<{$list.property_value_id}>|market_price'] = '<{$list.market_price}>';
			E_SPV['i_<{$list.property_value_id}>|stock'] = '<{$list.stock}>';
			E_SPV['i_<{$list.property_value_id}>|sku'] = '<{$list.code}>';
			E_SPV['i_<{$list.property_value_id}>|buy_limit'] = '<{$list.buy_limit}>';
			E_SPV['i_<{$list.property_value_id}>|weight'] = '<{$list.weight}>';

	<{/foreach}>
	
	V = E_SPV;
	
	
	$('.firstvalue').find('input[type="checkbox"]').each(function(){
		/* $('input[name="price"]').attr('readonly','readonly').css('background','#E7E7E7 none');
		$('input[name="show_price"]').attr('readonly','readonly').css('background','#E7E7E7 none');
		$('input[name="cost_price"]').attr('readonly','readonly').css('background','#E7E7E7 none'); 
		$('input[name="amount"]').attr('readonly','readonly').css('background','#E7E7E7 none');*/
		$('input[name="code"]').attr('readonly','readonly').css('background','#E7E7E7 none');
		$('tbody[nc_type="property_tbody"]').show();
	});

	into_set();
	str = '<tr>';
	
	<{$abc}>
	
	if(str == '<tr>'){
		
		//$('input[name="price"]').attr('readonly','').css('background','');
		//$('input[name="show_price"]').attr('readonly','').css('background','');
		//$('input[name="cost_price"]').attr('readonly','').css('background','');
		//$('input[name="amount"]').attr('readonly','').css('background','');
		//$('input[name="code"]').attr('readonly','').css('background','');
		$('tbody[nc_type="property_tbody"]').hide();
		$('#default_sku_setting').show();
	}
	
	
	if($('input[ignore_type]:checked').size()==0){
		$('tbody[nc_type="property_tbody"]').hide();
		$('#default_sku_setting').show();
	}

	$('tbody[nc_type="property_table"]')
		.empty()
		.html(str)
		.find('input[type="text"],input[type="hidden"]').each(function(){
			if($(this).is('[stock]')){
				$(this).attr('stock',$(this).siblings('input').val());
				var $stock=$(this);
				$.get('<{$config.weburl}>/admin/module.php?m=product&s=inventory_api.php&stock='+$(this).attr('stock'),function(data){
					$stock.val(data);
				});
			}else{
				s = $(this).attr('nc_type');
				if(s!='sp_value'){
					try{$(this).val(E_SPV[s])}catch(ex){$(this).val('')};	
				}
			}
		});
	
	$('#color').find('input[type="checkbox"]:checked').each(function(){
		pic_show($(this));
	});
});
/**********************zx**************/

//默认待选品牌
$('#brand').bind('click',function(e){
		$.get('<{$config.weburl}>/admin/module.php?m=product&s=product.php&operation=getbrand&brandname=',function(data){
			$('#brandlist').show();
			$('#brandlist').html(""+data);
		});
});
//直接搜品牌
$('#brand').bind('input',function(e){
	var value=$(this).val();
	if(value==''){
		$('#brandlist').hide();
		return ;
	}
	else{
		$.get('<{$config.weburl}>/admin/module.php?m=product&s=product.php&operation=getbrand&brandname='+value,function(data){
			$('#brandlist').show();
			$('#brandlist').html(""+data);
		});
	}
});
$('body').bind('click',function(e){
	$('#brandlist').hide();
});
$('#brandlist').delegate('li','click',function(){
	var _this=$(this);
	var brandName=_this.text();
		var brandId=_this.attr('bid');
		$('#brand').val(brandName);
		$('#brandid').val(brandId+'__'+brandName);
		$('#brandlist').hide();
});

/* parent.$data={};
$.each($('[stock]'),function(){
	//alert($(this).attr('stock'));
	var $stock=$(this);
	
	$.get('<{$config.weburl}>/admin/module.php?m=product&s=inventory_api.php&stock='+$(this).attr('stock'),function(data){
		$stock.is('td')?$stock.html(data):$stock.val(data);
		$.get('<{$config.weburl}>/admin/module.php?m=product&s=inventory_api.php&gettitle=1&stock='+$stock.attr('stock'),function(d){
			//alert(d);
			$('#gettitle').html(d);
		});
	});

	
}) */
</script>